//2806.取整购买后的账户余额
//https://leetcode.cn/problems/account-balance-after-rounded-purchase
class Solution {
public:
    int accountBalanceAfterPurchase(int purchaseAmount) {
        int x = purchaseAmount % 10;
        int y = 10 - x;
        if (purchaseAmount - x < purchaseAmount - y) return 100 - purchaseAmount - y;
        else if(purchaseAmount - x > purchaseAmount - y) return 100 - purchaseAmount + x;

        x = 100 - purchaseAmount + x;
        y = 100 - purchaseAmount - y;
        return min(x, y);
    }
};